
import {
  RecommendProductAction,
  FETCH_RECOMMEND_PRODUCTS_START,
  FETCH_RECOMMEND_PRODUCTS_SUCCESS,
  FETCH_RECOMMEND_PRODUCTS_FAIL,
} from "./productAction";
export interface RecProductState {
  error: string | null;
  loading: boolean;
  productList: any[];
}
const defaultState: RecProductState = {
  productList: [],
  error: null,
  loading: true,
};

export default function ProductReducer(state = defaultState, action:RecommendProductAction) {
  switch (action.type) {
    case FETCH_RECOMMEND_PRODUCTS_START:
      return {
        ...state,
      };

    case FETCH_RECOMMEND_PRODUCTS_SUCCESS:
      return {
        productList: action.payload,

        loading: false,
        error: null,
      };
    case FETCH_RECOMMEND_PRODUCTS_FAIL:
      return {
        productList: [],

        loading: false,
        error: action.payload,
      };
    default:
      return state;
  }
}
